package com.wcs.exam.controller.admin;

import com.wcs.exam.common.base.Result;
import com.wcs.exam.common.base.annotation.OptLog;
import com.wcs.exam.common.base.page.Page;
import com.wcs.exam.controller.admin.biz.AdminTagBiz;
import com.wcs.exam.controller.admin.req.*;
import com.wcs.exam.controller.admin.resp.AdminTagListResp;
import com.wcs.exam.controller.admin.resp.AdminTagPageResp;
import com.wcs.exam.controller.admin.resp.AdminTagSaveResp;
import com.wcs.exam.controller.admin.resp.AdminTagViewResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Admin-标签信息
 *
 * @author wcs
 * @since 2025-03-17
 */
@Tag(name = "Admin-标签信息")
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/admin/tag")
public class AdminTagController {

    @NotNull
    private final AdminTagBiz biz;

    @Operation(summary = "标签信息-分页")
    @GetMapping(value = "/page")
    public Result<Page<AdminTagPageResp>> page(@ModelAttribute AdminTagPageReq req) {
        return biz.page(req);
    }

    @Operation(summary = "标签信息-列表", description = "标签信息-列表")
    @GetMapping(value = "/list")
    public Result<List<AdminTagListResp>> list(@ModelAttribute AdminTagListReq req) {
        return biz.list(req);
    }

    @Operation(summary = "标签信息-添加")
    @OptLog(value = "标签信息添加")
    @PostMapping(value = "/save")
    public Result<String> save(@RequestBody @Valid AdminTagSaveReq req) {
        return biz.save(req);
    }

    @Operation(summary = "标签信息添加(返回数据)", description = "标签信息添加(返回数据)")
    @OptLog(value = "标签信息添加(返回数据)")
    @PostMapping(value = "/save/data")
    public Result<AdminTagSaveResp> saveData(@RequestBody @Valid AdminTagSaveReq req) {
        return biz.saveData(req);
    }

    @Operation(summary = "标签信息-查看")
    @Parameter(name = "id", description = "主键ID", required = true)
    @GetMapping(value = "/view")
    public Result<AdminTagViewResp> view(@RequestParam Long id) {
        return biz.view(id);
    }

    @Operation(summary = "标签信息-编辑")
    @PutMapping(value = "/edit")
    public Result<String> edit(@RequestBody @Valid AdminTagEditReq req) {
        return biz.edit(req);
    }

    @Operation(summary = "标签信息-编辑状态")
    @OptLog(value = "标签信息编辑状态")
    @PutMapping(value = "/edit/status")
    public Result<String> editStatus(@RequestBody @Valid AdminTagEditStatusReq req) {
        return biz.editStatus(req);
    }

    @Operation(summary = "标签信息-排序")
    @PutMapping(value = "/sort")
    public Result<String> sort(@RequestBody @Valid List<AdminTagSortReq> reqs) {
        return biz.sort(reqs);
    }

    @Operation(summary = "标签信息-删除")
    @Parameter(name = "id", description = "主键ID", required = true)
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam Long id) {
        return biz.delete(id);
    }
}
